package com.example.activelifecycletest.login;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;

import androidx.appcompat.app.AlertDialog;

/**
 * 强制下线广播
 * @author zhangding
 * @date 2022年04月22日11:51:35
 */
public class ForceOfflineReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("警告");
        builder.setMessage("你被强制下线！请尝试重新登录");
        builder.setCancelable(false);
        builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int which) {
                ActivityConllector.finishAll();
                Intent i = new Intent(context,LoginActivity.class);
                context.startActivity(i);
            }
        });
        builder.show();
    }
}